'''
Description: 
Author: Qingyou Fang
Date: 2023-09-16 08:52:38
LastEditTime: 2023-09-19 14:54:10
LastEditors:  
'''
import time
import uuid
import hashlib

from app.utils.utils_pysnowflake import IdWorker

worker = IdWorker()


def generate_id():
    """

    """
    id = worker.get_id()
    print(id)
    return id

def get_timestamp_ms():
    """

    """
    timestamp_s = time.time()
    timestamp_ms = int(timestamp_s*1000)
    
    return timestamp_ms

def get_timestamp_s():
    """

    """
    timestamp_s = time.time()
    
    return int(timestamp_s)


def generate_uuid(separator="====", only_uuid=True):
    """

    """

    id = generate_id() 
    uuid_id = uuid.uuid4()

    plaintext = f"{id}{separator}{uuid_id}"

    ciphertext = hashlib.sha256(plaintext.encode("utf-8")).hexdigest()

    if only_uuid:
        return ciphertext

    return ciphertext, id, separator, uuid_id

    

    